package com.bdqn.hospital.service.impl;

import com.bdqn.hospital.mapper.PatientMapper;
import com.bdqn.hospital.pojo.Patient;
import com.bdqn.hospital.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

/**
 * @version : 1.0
 * @Author :guogd
 * @createTime: 2023/03/01 14:55
 * @Description: com.bdqn.hospital.service.impl
 */
@Service
public class PatientServiceImpl implements PatientService {
    @Autowired
    private PatientMapper patientMapper;
    @Override
    public Patient getPatientById(Integer id) {
        return patientMapper.getPatientById(id);
    }

    @Override
    public Integer addPatient(Patient patient) {
        return patientMapper.addPatient(patient);
    }

    @Override
    public Patient getPatientByIdCard(String idCard) {
        return patientMapper.getByIdCard(idCard);
    }

    @Override
    public Integer checkAddPatient(String idCard, String idMedicare) {
        Patient p1 = patientMapper.getByIdCard(idCard);
        Patient p2 = patientMapper.getByIdMedicare(idMedicare);
        if(p2!=null && idMedicare!=""){
            return 3;//医保卡已被使用
        }else if(p1!=null && p2!=null && idMedicare!=""){
            return 4;//医保卡和身份证都不可用
        }else if(p1!=null){
            return 2;//身份证重复
        }else{
            return 1;//身份证可用并且医保卡也可用
        }
    }
}
